<!DOCTYPE html>
<html lang="en">





<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/zezhang/img/favicon.webp">
  <link rel="icon" type="image/png" href="/zezhang/img/favicon.webp">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="">
  <meta name="author" content="ZeZhang">
  <meta name="keywords" content="">
  <title>数组常用操作(含ES6) - 你那里天气还好吗?</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/zezhang/lib/hint/hint.min.css" />

  
    <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/github-gist.min.css" />
  

  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_yg9cfy8wd6.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_pjno9b9zyxs.css">


<link  rel="stylesheet" href="/zezhang/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/zezhang/js/utils.js" ></script>
<meta name="generator" content="Hexo 4.2.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/zezhang/">&nbsp;<strong>你那里天气还好吗?</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/zezhang/">
                <i class="iconfont icon-home-fill"></i>
                Home
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/zezhang/archives/">
                <i class="iconfont icon-archive-fill"></i>
                Archives
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/zezhang/tags/">
                <i class="iconfont icon-tags-fill"></i>
                Tags
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/zezhang/about/">
                <i class="iconfont icon-user-fill"></i>
                About
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="view intro-2" id="background" parallax=true
         style="background: url('/zezhang/img/banner8.webp') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container text-center white-text fadeInUp">
            <span class="h2" id="subtitle">
              
            </span>

            
              
  <div class="mt-3 post-meta">
    <i class="iconfont icon-date-fill" aria-hidden="true"></i>
    <time datetime="2020-03-11 15:27">
      March 11, 2020 pm
    </time>
  </div>


<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      1k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      14
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <div class="post-content mx-auto" id="post">
            
            <article class="markdown-body">
              <a id="more"></a>

<h3 id="1-concat"><a href="#1-concat" class="headerlink" title="1.concat()"></a>1.concat()</h3><p>concat()方法用于连接两个或者多个数组.该方法不会改变现有的数组,仅会返回被连接数组的一个副本</p>
<pre><code class="hljs js"><span class="hljs-keyword">var</span> arr1=[<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>];
<span class="hljs-keyword">var</span> arr2=[<span class="hljs-number">4</span>,<span class="hljs-number">5</span>];
<span class="hljs-keyword">var</span> arr3=arr1.concat(arr2)
<span class="hljs-built_in">console</span>.log(arr1);<span class="hljs-comment">//[1,2,3]</span>
<span class="hljs-built_in">console</span>.log(arr3);<span class="hljs-comment">//[1,2,3,4,5]</span></code></pre>

<h3 id="2-join"><a href="#2-join" class="headerlink" title="2.join()"></a>2.join()</h3><p>join()方法用于把数组中的所有元素放入一个字符串,元素是通过制定的分隔符进行隔离的,默认是用”分隔,不会改变原数组.</p>
<pre><code class="hljs js"><span class="hljs-keyword">var</span> arr=[<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>];
<span class="hljs-built_in">console</span>.log(arr.join());<span class="hljs-comment">//2,3,4</span>
<span class="hljs-built_in">console</span>.log(arr);<span class="hljs-comment">//[2,3,4]</span></code></pre>

<h3 id="3-push"><a href="#3-push" class="headerlink" title="3.push()"></a>3.push()</h3><p>push()方法可用于数组末尾添加一个或者多个元素,并返回新的长度.会改变原数组</p>
<pre><code class="hljs js"><span class="hljs-keyword">var</span> a=[<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>];
<span class="hljs-keyword">var</span> b=a.push(<span class="hljs-number">5</span>)
<span class="hljs-built_in">console</span>.log(a); <span class="hljs-comment">//[2,3,4,5]</span>
<span class="hljs-built_in">console</span>.log(b); <span class="hljs-comment">//4 为数组的长度</span></code></pre>

<h3 id="4-pop"><a href="#4-pop" class="headerlink" title="4.pop()"></a>4.pop()</h3><p>pop()方法用于删除并返回数组的最后一个元素.会改变原数组。</p>
<pre><code class="hljs js"><span class="hljs-keyword">var</span> arr = [<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>];
<span class="hljs-built_in">console</span>.log(arr.pop()); <span class="hljs-comment">//4</span>
<span class="hljs-built_in">console</span>.log(arr); <span class="hljs-comment">//[2,3]</span></code></pre>

<h3 id="5-shift"><a href="#5-shift" class="headerlink" title="5.shift()"></a>5.shift()</h3><p>shift() 方法用于把数组的第一个元素从其中删除，并返回第一个元素的值。返回第一个元素，改变原数组。</p>
<pre><code class="hljs js"><span class="hljs-keyword">var</span> arr = [<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>];
<span class="hljs-built_in">console</span>.log(arr.shift()); <span class="hljs-comment">//2</span>
<span class="hljs-built_in">console</span>.log(arr); <span class="hljs-comment">//[3,4]</span></code></pre>

<h3 id="6-unshift"><a href="#6-unshift" class="headerlink" title="6.unshift"></a>6.unshift</h3><p>unshift() 方法可向数组的开头添加一个或更多元素，并返回新的长度。返回新长度，改变原数组。</p>
<pre><code class="hljs js"><span class="hljs-keyword">var</span> arr = [<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>];
<span class="hljs-built_in">console</span>.log(arr.unshift(<span class="hljs-number">3</span>,<span class="hljs-number">6</span>)); <span class="hljs-comment">//6</span>
<span class="hljs-built_in">console</span>.log(arr); <span class="hljs-comment">//[3, 6, 2, 3, 4, 5]</span></code></pre>

<p>tip:该方法可以不传参数,不传参数就是不增加元素。</p>
<h3 id="7-splice"><a href="#7-splice" class="headerlink" title="7.splice()"></a>7.splice()</h3><p><em>splice() 方法可删除从 index 处开始的零个或多个元素，并且用参数列表中声明的一个或多个值来替换那些被删除的元素。如果从 arrayObject 中删除了元素，则返回的是含有被删除的元素的数组。splice() 方法会直接对数组进行修改。</em></p>
<pre><code class="hljs js"><span class="hljs-keyword">var</span> a = [<span class="hljs-number">5</span>,<span class="hljs-number">6</span>,<span class="hljs-number">7</span>,<span class="hljs-number">8</span>];
<span class="hljs-built_in">console</span>.log(a.splice(<span class="hljs-number">1</span>,<span class="hljs-number">0</span>,<span class="hljs-number">9</span>)); <span class="hljs-comment">//[]</span>
<span class="hljs-built_in">console</span>.log(a); <span class="hljs-comment">// [5, 9, 6, 7, 8]</span>
<span class="hljs-keyword">var</span> b = [<span class="hljs-number">5</span>,<span class="hljs-number">6</span>,<span class="hljs-number">7</span>,<span class="hljs-number">8</span>];
<span class="hljs-built_in">console</span>.log(b.splice(<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>)); <span class="hljs-comment">//[6, 7]</span>
<span class="hljs-built_in">console</span>.log(b); <span class="hljs-comment">//[5, 3, 8]</span></code></pre>

<h3 id="8-slice"><a href="#8-slice" class="headerlink" title="8.slice()"></a>8.slice()</h3><p>返回一个新的数组，包含从 start 到 end （不包括该元素）的 arrayObject 中的元素。返回选定的元素，该方法不会修改原数组。</p>
<pre><code class="hljs js"><span class="hljs-keyword">var</span> arr = [<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>];
<span class="hljs-built_in">console</span>.log(arr.slice(<span class="hljs-number">1</span>,<span class="hljs-number">3</span>)); <span class="hljs-comment">//[3,4]</span>
<span class="hljs-built_in">console</span>.log(arr); <span class="hljs-comment">//[2,3,4,5]</span></code></pre>

<h3 id="9-sort"><a href="#9-sort" class="headerlink" title="9.sort()"></a>9.sort()</h3><p>按照 Unicode code 位置排序，默认升序</p>
<pre><code class="hljs js">fruit.sort(); <span class="hljs-comment">// ['apples', 'bananas', 'cherries']</span>
<span class="hljs-keyword">var</span> scores = [<span class="hljs-number">1</span>, <span class="hljs-number">10</span>, <span class="hljs-number">21</span>, <span class="hljs-number">2</span>];
scores.sort(); <span class="hljs-comment">// [1, 10, 2, 21]</span></code></pre>

<h3 id="10-reverse"><a href="#10-reverse" class="headerlink" title="10.reverse()"></a>10.reverse()</h3><p>reverse() 方法用于颠倒数组中元素的顺序。返回的是颠倒后的数组，会改变原数组。</p>
<pre><code class="hljs js"><span class="hljs-keyword">var</span> arr = [<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>];
<span class="hljs-built_in">console</span>.log(arr.reverse()); <span class="hljs-comment">//[4, 3, 2]</span>
<span class="hljs-built_in">console</span>.log(arr); <span class="hljs-comment">//[4, 3, 2]</span></code></pre>

<h3 id="11-indexOf-和-lastIndexOf"><a href="#11-indexOf-和-lastIndexOf" class="headerlink" title="11.indexOf 和 lastIndexOf"></a>11.indexOf 和 lastIndexOf</h3><p>都接受两个参数：查找的值、查找起始位置<br>不存在，返回 -1 ；存在，返回位置。indexOf 是从前往后查找， lastIndexOf 是从后往前查找。</p>
<pre><code class="hljs js">indexOf
<span class="hljs-keyword">var</span> a = [<span class="hljs-number">2</span>, <span class="hljs-number">9</span>, <span class="hljs-number">9</span>];
a.indexOf(<span class="hljs-number">2</span>); <span class="hljs-comment">// 0</span>
a.indexOf(<span class="hljs-number">7</span>); <span class="hljs-comment">// -1</span>
 
<span class="hljs-keyword">if</span> (a.indexOf(<span class="hljs-number">7</span>) === <span class="hljs-number">-1</span>) &#123;
 <span class="hljs-comment">// element doesn't exist in array</span>
&#125;
lastIndexOf
 
<span class="hljs-keyword">var</span> numbers = [<span class="hljs-number">2</span>, <span class="hljs-number">5</span>, <span class="hljs-number">9</span>, <span class="hljs-number">2</span>];
numbers.lastIndexOf(<span class="hljs-number">2</span>);  <span class="hljs-comment">// 3</span>
numbers.lastIndexOf(<span class="hljs-number">7</span>);  <span class="hljs-comment">// -1</span>
numbers.lastIndexOf(<span class="hljs-number">2</span>, <span class="hljs-number">3</span>); <span class="hljs-comment">// 3</span>
numbers.lastIndexOf(<span class="hljs-number">2</span>, <span class="hljs-number">2</span>); <span class="hljs-comment">// 0</span>
numbers.lastIndexOf(<span class="hljs-number">2</span>, <span class="hljs-number">-2</span>); <span class="hljs-comment">// 0</span>
numbers.lastIndexOf(<span class="hljs-number">2</span>, <span class="hljs-number">-1</span>); <span class="hljs-comment">// 3</span></code></pre>

<h3 id="12-every"><a href="#12-every" class="headerlink" title="12.every()"></a>12.every()</h3><p>对数组的每一项都运行给定的函数，每一项都返回 ture,则返回 true</p>
<pre><code class="hljs js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">isBigEnough</span>(<span class="hljs-params">element, index, array</span>) </span>&#123;
 <span class="hljs-keyword">return</span> element &lt; <span class="hljs-number">10</span>;
&#125;
[<span class="hljs-number">2</span>, <span class="hljs-number">5</span>, <span class="hljs-number">8</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>].every(isBigEnough); <span class="hljs-comment">// true</span></code></pre>

<h3 id="13-some"><a href="#13-some" class="headerlink" title="13.some()"></a>13.some()</h3><p>对数组的每一项都运行给定的函数,任意一项是true,就返回true</p>
<pre><code class="hljs js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">compare</span>(<span class="hljs-params">element, index, array</span>) </span>&#123;
 <span class="hljs-keyword">return</span> element &gt; <span class="hljs-number">10</span>;
&#125; 
[<span class="hljs-number">2</span>, <span class="hljs-number">5</span>, <span class="hljs-number">8</span>, <span class="hljs-number">1</span>, <span class="hljs-number">4</span>].some(compare); <span class="hljs-comment">// false</span>
[<span class="hljs-number">12</span>, <span class="hljs-number">5</span>, <span class="hljs-number">8</span>, <span class="hljs-number">1</span>, <span class="hljs-number">4</span>].some(compare); <span class="hljs-comment">// true</span></code></pre>

<h3 id="14-filter"><a href="#14-filter" class="headerlink" title="14.filter()"></a>14.filter()</h3><p>对数组的每一项都运行给定的函数，返回 结果为 ture 的项组成的数组</p>
<pre><code class="hljs js"><span class="hljs-keyword">var</span> words = [<span class="hljs-string">"spray"</span>, <span class="hljs-string">"limit"</span>, <span class="hljs-string">"elite"</span>, <span class="hljs-string">"exuberant"</span>, <span class="hljs-string">"destruction"</span>, <span class="hljs-string">"present"</span>, <span class="hljs-string">"happy"</span>];
<span class="hljs-keyword">var</span> longWords = words.filter(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">word</span>)</span>&#123;
 <span class="hljs-keyword">return</span> word.length &gt; <span class="hljs-number">6</span>;
&#125;);
<span class="hljs-comment">// Filtered array longWords is ["exuberant", "destruction", "present"]</span></code></pre>

<h3 id="15-map"><a href="#15-map" class="headerlink" title="15.map()"></a>15.map()</h3><p>对数组的每一项都运行给定的函数，返回每次函数调用的结果组成一个新数组</p>
<pre><code class="hljs js"><span class="hljs-keyword">var</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">5</span>, <span class="hljs-number">10</span>, <span class="hljs-number">15</span>];
<span class="hljs-keyword">var</span> doubles = numbers.map(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">x</span>) </span>&#123;
  <span class="hljs-keyword">return</span> x * <span class="hljs-number">2</span>;
&#125;);
<span class="hljs-comment">// doubles is now [2, 10, 20, 30]</span>
<span class="hljs-comment">// numbers is still [1, 5, 10, 15]</span></code></pre>

<h3 id="16-forEach-数组遍历"><a href="#16-forEach-数组遍历" class="headerlink" title="16.forEach()数组遍历"></a>16.forEach()数组遍历</h3><pre><code class="hljs js"><span class="hljs-keyword">const</span> items = [<span class="hljs-string">'item1'</span>, <span class="hljs-string">'item2'</span>, <span class="hljs-string">'item3'</span>];
<span class="hljs-keyword">const</span> copy = []; 
items.forEach(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">item</span>)</span>&#123;
 copy.push(item)
&#125;);</code></pre>


            </article>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/zezhang/tags/JavaScript/">JavaScript</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" target="_blank" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！</p>
              
              
                <div class="post-prevnext row">
                  <div class="post-prev col-6">
                    
                    
                      <a href="/zezhang/2020/03/14/seo%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E4%B9%8Bnuxt.js/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">seo解决方案之nuxt</span>
                        <span class="visible-mobile">Previous</span>
                      </a>
                    
                  </div>
                  <div class="post-next col-6">
                    
                    
                      <a href="/zezhang/2020/03/09/this%E6%8C%87%E5%90%91%E9%97%AE%E9%A2%98/">
                        <span class="hidden-mobile">this指向问题</span>
                        <span class="visible-mobile">Next</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </div>
                </div>
              
            </div>

            
          </div>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;TOC</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">Search</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">keyword</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  

  <footer class="mt-5">
  <div class="text-center py-3">
    <div>
      <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a>
      <i class="iconfont icon-love"></i>
      <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener">
        <span>Fluid</span></a>
    </div>
    
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


    

    
  </div>
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/zezhang/js/debouncer.js" ></script>
<script  src="/zezhang/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/zezhang/js/lazyload.js" ></script>
  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/zezhang/js/clipboard-use.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: 'article.markdown-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "数组常用操作(含ES6)&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/zezhang/js/local-search.js" ></script>
  <script>
    var path = "/zezhang/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>




















</body>
</html>
